﻿@model IEnumerable<EC_ASS.Models.Feedback>

@{
    ViewBag.Title = "Category";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}

<script type="text/javascript">
    $(function () {
        $('.delete-feedback').click(function () {
            var fbID = $(this).attr('feedbackID');
            var deleteUrl = this.href;
            $.ajax({
                type: "GET",
                url: deleteUrl,
                data: { id: fbID },
                success: function (result) {
                }
            });
            setTimeout(function () {
                $('#listFeedbackTable').load('@Url.Action("_ListFeedbackPage", "Admin")').hide().fadeIn('slow');
            }, 2000);
            return false;
        });
    });
</script>
<br />
<!--Edit modal-->
<div>
    <div id='editModal' class='modal hide fade in'>
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h3>Thông tin</h3>
        </div>
        <div id='editModalContent'></div>
        <div id="editLoading" style="margin-top: 20px; margin-bottom: 20px;">
            <center>
                <img src="@Url.Content("~/img/ajax-loader.gif")" />
            </center>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        $('.edit-feedback').click(function () {
            var itemID = $(this).attr('feedbackID');
            var editUrl = this.href + '/' + itemID;
            $('#editModalContent').load(editUrl, function () {
                $('#editModal').modal({
                    backdrop: 'static',
                    keyboard: true
                }, 'show');
                $('#editLoading').hide();
            });
            return false;
        });
    });
</script>
<div id="listFeedbackTable" style="margin-top: -20px">
    <table class="table table-bordered">
        <thead>
            <th>Khách hàng</th>
            <th>Email</th>
            <th>Nội dung</th>
            <th>Ngày feedback</th>
            <th>Thao tác</th>
        </thead>
        <tbody>
            @foreach (var item in Model)
            {
                <tr class="success">
                    <td>@item.Customer</td>
                    <td>@item.Email</td>
                    @if (item.Content.Length > 20)
                    {
                        <td>
                            @(item.Content.Substring(0, 17) + " ...")
                        </td>
                    }
                    else
                    {
                        <td>
                            @item.Content
                        </td>
                    }
                    <td>@item.Time</td>
                    <td>
                        @Html.ActionLink("Sữa", "EditFeedback", "Admin", null, new { @class = "btn edit-feedback", @feedbackID = item.ID })
                        @Html.ActionLink("Xóa", "DeleteFeedback", "Admin", null, new { @class = "btn delete-feedback", @feedbackID = item.ID })                        
                    </td>
                </tr>
        }
        </tbody>
    </table>
</div>


